﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace StoreWeb.system.basis
{
    public partial class valueedit : System.Web.UI.Page
    {
        Maticsoft.BLL.valuetype bll = new Maticsoft.BLL.valuetype();
        //Maticsoft.BLL.DictionaryType dbll = new Maticsoft.BLL.DictionaryType();
        Maticsoft.BLL.InventoryClass blls = new Maticsoft.BLL.InventoryClass();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                hidid.Value = Request.QueryString["id"];
                this.ckboxlist.DataSource = blls.GetList("(cInvCCode like '05%') and bInvCEnd=1");
                this.ckboxlist.DataTextField = "cInvCName";
                this.ckboxlist.DataValueField = "cInvCCode";
                this.ckboxlist.DataBind();
                if (!string.IsNullOrEmpty(hidid.Value))
                {
                    //this.parentlist.DataSource = bll.GetList("parentcode=0 and id<>" + hidid.Value);
                    //this.parentlist.DataTextField = "name";
                    //this.parentlist.DataValueField = "code";
                    //this.parentlist.DataBind();
                    //this.parentlist.Items.Insert(0, new ListItem("--请选择上级属性--", "0"));

                    Maticsoft.Model.valuetype md = bll.GetModel(Convert.ToInt32(hidid.Value));
                    note.Value = md.note;
                    name.Value = md.name;
                    code.Value = md.code;
                    //parentlist.SelectedValue = md.parentcode;
                    ddlisttype.SelectedValue = md.vtype.ToString();
                    value.Value = md.value;
                    foreach (ListItem item in ckboxlist.Items)
                    {
                        if (md.cInvCCodes.Split('|').Contains(item.Value))
                        {
                            item.Selected = true;
                        }
                    }
                    foreach (ListItem item in rdoistext.Items)
                    {
                        if (md.parentcode.Contains(item.Value))
                        {
                            item.Selected = true;
                        }
                    }
                    
                }
                else 
                {
                    code.Value = "ZZ" + DateTime.Now.ToString("yyMMddHHmmss");
                }
                //else
                //{
                //    this.parentlist.DataSource = bll.GetList("parentcode=0");
                //    this.parentlist.DataTextField = "name";
                //    this.parentlist.DataValueField = "code";
                //    this.parentlist.DataBind();
                //    this.parentlist.Items.Insert(0, new ListItem("--请选择上级属性--", "0"));
                //}
            }
        }
    }
}